<?php


namespace api\app\controller;


use api\app\model\GoodsModel;
use cmf\controller\RestBaseController;

class GoodsController extends RestBaseController
{
    public function goodsList()
    {
        $id = input('id');
        if (!$id) {
            $this->error('参数错误');
        }
        $goods = GoodsModel::find($id);
        if (!$goods) {
            $this->error('未有该商品');
        }
        unset($goods['info'],$goods['update_time'],$goods['delete_time']);
        $goodsInfo = json_decode($goods['val_info'],true);
        foreach ($goodsInfo as $key => $value) {
            $goodsInfo[$key]['attrVal'] = explode(',',$value['attrVal']);
        }
        $goods['val_info'] = $goodsInfo;
        $this->success('商品详情',$goods);
    }


}